import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CompanyVO, CompanyForm, CompanyQuery } from '@/api/base/company/types';

/**
 * 查询公司列表
 * @param query
 * @returns {*}
 */
export const pageCompany = (query?: CompanyQuery): AxiosPromise<CompanyVO[]> => {
  return request({
    url: '/base/company/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询公司列表
 * @param query
 * @returns {*}
 */
export const listCompany = (query?: CompanyQuery): AxiosPromise<CompanyVO[]> => {
  return request({
    url: '/base/company/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询公司详细
 * @param companyId
 */
export const getCompany = (companyId: string | number): AxiosPromise<CompanyVO> => {
  return request({
    url: '/base/company/' + companyId,
    method: 'get'
  });
};

/**
 * 新增公司
 * @param data
 */
export const addCompany = (data: CompanyForm) => {
  return request({
    url: '/base/company',
    method: 'post',
    data: data
  });
};

/**
 * 修改公司
 * @param data
 */
export const updateCompany = (data: CompanyForm) => {
  return request({
    url: '/base/company',
    method: 'put',
    data: data
  });
};

/**
 * 删除公司
 * @param companyId
 */
export const delCompany = (companyId: string | number | Array<string | number>) => {
  return request({
    url: '/base/company/' + companyId,
    method: 'delete'
  });
};
